#include <iostream>
#include <pthread.h>
#include <unistd.h>
#include <vector>
const int Threadnum = 5;
struct ThreadData
{
    int x;
    int y;
    char op;
    /* data */
};

struct res
{
    int code;
    int result;
};


class InAndOut
{

public:
    int who;
    std::vector<ThreadData>datas;
    std::vector<res> results;
};

class ThreadRetrun
{
public:
    ThreadRetrun(pthread_t id, std::string info, int code)
    :_id(id), _info(info), _code(code)
    {}
    void Printinfo()
    {
        std::cout << "retid:" << _id << std::endl << "info:" << _info << std::endl << "retcode" << _code << std::endl;
    }
public:
    pthread_t _id;
    std::string _info;
    int _code;
};
void *ThreadRoutine(void *args)
{
    pthread_detach(pthread_self());
    std::string num = static_cast<const char *>(args);
    std::cout << "This is a new thread"  << num << std::endl;
    ThreadRetrun* retinfo = new ThreadRetrun(pthread_self(), "exit normal", 1);
    sleep(1);
    return (void *)retinfo;
}
int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, ThreadRoutine, (void*)"1");  
    int retval;     
    void* ret;
    retval = pthread_join(tid, &ret);
    ThreadRetrun* retinfo = static_cast<ThreadRetrun *>(ret); 
    sleep(2);
    std::cout << "main thread over. retval:" << retval << "ret:";
    retinfo->Printinfo();
    return 0;
}